const fs = require('fs')
const path = require('path')

fs.readFile(path.join( __dirname + '/data/data.json'),async ( err, data) => {
  if (err) return console.log(err);
  const obj = JSON.parse(data.toString())
  const male = obj.filter( res => res.gender == '男')
  const female = obj.filter(res => res.gender == '女')
  await fs.writeFile(path.join( __dirname + '/男.json'), JSON.stringify(male), (err, data) => {if (err) return console.log(err)})
  await fs.writeFile(path.join( __dirname + '/女.json'), JSON.stringify(female), (err, data) => {if (err) return console.log(err)})
})